<template>
  <div class="recommend">

    <div class="recommend-main">
      <div class="item"
        v-for="(item, index) in items"
        :key="item.id"
        @click="clickItem(item.id, index)"
      >
        <img :src="item.pic" alt="" class="itemImg">
        <h5 class="itemName">
          {{item.name}}
        </h5>
        <div class="itemAction">
          <p class="price">
            {{item.minPrice | currency}}
          </p>
          <van-icon color="#f66" name="add" size="24"></van-icon>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { currency } from '../../../filters'
export default {
  props: {
    items: {
      type: Array,
      required: true
    }
  },
  methods: {
    clickItem (id, index) {
      // 点击商品
      this.$emit('click', {id, index})
    }
  },
  filters: {
    currency
  }
}
</script>

<style lang="scss" scoped>
.recommend{
  &-head{
    h3{
        font-size: 18PX;
        color: #333;
       font-weight: normal;
    }
  
    line-height: 40PX;
    padding-left: 10px;
    background: #f1f1f1;
   
  }
  &-main{
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    .item{
      width: 45%;
      
      .itemName{
        font-size: 14PX;
        font-weight: normal;
        color: #666;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
      }
      .itemAction{
        display: flex;
        height:40px;
        justify-content: space-between;
        align-items: center;
        .price{
          font-size: 18PX;
          color:#f34;
        }
      }
      img{
        width:100%;
      }
    }
  }
}
</style>
